#include <ros/ros.h>
#include <pluginlib/class_list_macros.h>
#include <nodelet/nodelet.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl_visualization/cloud_viewer.h>
#include <pcl_ros/point_cloud.h>

namespace HelloNodelet
{
typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloud;

class TTKinect : public nodelet::Nodelet
{
public:
virtual void onInit()
{
viewer = new pcl_visualization::CloudViewer("Cloud 3D");
ros::NodeHandle & nh = getNodeHandle();
sub_ = nh.subscribe<PointCloud >("cloud_in",2, &TTKinect::callback, this);

}
void callback(const PointCloud::ConstPtr &cloud)
{
if(!viewer->wasStopped())
{
viewer->showCloud(*cloud);
}
}
~TTKinect()
{
if(viewer != NULL) delete viewer;
}

private:
ros::Publisher pub_;
ros::Subscriber sub_;
pcl_visualization::CloudViewer *viewer;

};

PLUGINLIB_DECLARE_CLASS(HelloNodelet, TTKinect, HelloNodelet::TTKinect, nodelet::Nodelet);
}